# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs,lib, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
 # boot.loader.grub.enable = true;
 # boot.loader.grub.device = "/dev/sda";
 # boot.loader.grub.useOSProber = true;

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  
  nix.settings.experimental-features = [ "nix-command" "flakes" ];
  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  services.pipewire.enable = true;
  services.pipewire.alsa.enable = true;
  sound.enable = true; 
  #要想使用steam需要启用该选项
  hardware.opengl.driSupport32Bit = true;
  # Configure network proxy if necessary
  # networking.proxy.default = "http://127.0.0.1:7890/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Asia/Shanghai";

  # Select internationalisation properties.
  i18n.defaultLocale = "zh_CN.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "zh_CN.UTF-8";
    LC_IDENTIFICATION = "zh_CN.UTF-8";
    LC_MEASUREMENT = "zh_CN.UTF-8";
    LC_MONETARY = "zh_CN.UTF-8";
    LC_NAME = "zh_CN.UTF-8";
    LC_NUMERIC = "zh_CN.UTF-8";
    LC_PAPER = "zh_CN.UTF-8";
    LC_TELEPHONE = "zh_CN.UTF-8";
    LC_TIME = "zh_CN.UTF-8";
  };
  i18n.inputMethod = {
      enabled = "fcitx5";
      fcitx5.addons = with pkgs; [
      fcitx5-chinese-addons
      fcitx5-gtk       
      ];
  
  };
  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "cn";
    variant = "";
  };

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.tts = {
    isNormalUser = true;
    description = "tts";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [];
  };

  # Enable automatic login for the user.
  services.getty.autologinUser = "tts";

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;
 
  virtualisation.virtualbox.host.enable = true;
  users.extraGroups.vboxusers.members = [ "tts" ];
  virtualisation.virtualbox.host.enableExtensionPack = true;
  virtualisation.virtualbox.host.enableHardening = false;
  virtualisation.virtualbox.guest.enable = true;
  virtualisation.virtualbox.guest.draganddrop = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
     neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
     cmake
     xmake
     gdb
     gcc
     gtk3-x11
     gtk3
     gtkmm3
     libgcc
     gnumake
     clang_18
     python3
     unzip
     meson
     flutter
     pkg-config
     graphite2
     qtcreator
     libsForQt5.full
     wget
     git
     kitty
     noto-fonts-cjk-sans
     noto-fonts
     wqy_microhei
     wqy_zenhei
     protonup-qt
     ranger
     dolphin
     wofi
     swaybg
     eww
     telegram-desktop
     #nerdfonts
     vscode-fhs
     dpkg
     wl-clipboard
     microsoft-edge
     steam
     virtualbox
     qemu
     #自定义包
     (pkgs.callPackage /home/tts/my-nix-config/.app/clash-linux-amd64.nix {})
     (pkgs.callPackage /home/tts/my-nix-config/.app/tproxy/tproxy.nix {})
     (pkgs.callPackage /home/tts/my-nix-config/.app/tnix/tnix.nix {})
 
    ];
    programs.hyprland.enable = true;
    environment.variables.EDITOR = "nvim";    
    programs.neovim.defaultEditor = true;
    #programs.nix-ld.enable = true;
    #programs.nix-ld.libraries = with pkgs; [
    # Add any missing dynamic libraries for unpackaged programs
    # here, NOT in environment.systemPackages
    #];
  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
    services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  nix.settings.substituters =  [
     "https://mirrors.cernet.edu.cn/nix-channels/store"
     "https://mirror.sjtu.edu.cn/nix-channels/store"  
  ];
  system.stateVersion = "24.05"; # Did you read the comment?

}
